package com.xigua._树;

import com.xigua.TreeNode;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: 给定二叉树的根节点 root ，返回所有左叶子之和。
 * @date 2022/4/123:20
 */
public class _404_左叶子之和 {


    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null ) return 0;
        if (root.left == null) return sumOfLeftLeaves(root.right);
        if (root.left.left == null && root.left.right == null) return root.left.val+sumOfLeftLeaves(root.right)+sumOfLeftLeaves(root.left.right);
        return sumOfLeftLeaves(root.left)+sumOfLeftLeaves(root.right);
    }
}
